﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Dapper_Core.Web
{
    /// <summary>
    /// 对一级部门、二级部门、三级部门、部门经理控件联动进行封装
    /// 视图组件类必须继承ViewComponent
    /// 父视图中的ViewData、ViewBag可以在视图组件中使用
    /// 视图组件中的ViewData、ViewBag不能在父视图中使用
    /// 视图放在Shared/Components/ThirdLevelDept目录下，默认返回Default.cshtml
    /// </summary>
    public class ThirdLevelDeptViewComponent : ViewComponent
    {
        public async Task<IViewComponentResult> InvokeAsync(string firstDeptId, string secondDeptId, string thirdDeptId, bool handleDeptManager, string deptManagerId, string deptId)
        {
            ViewData["firstDeptId"] = firstDeptId;
            ViewData["secondDeptId"] = secondDeptId;
            ViewData["thirdDeptId"] = thirdDeptId;
            ViewData["handleDeptManager"] = handleDeptManager;
            ViewData["deptManagerId"] = deptManagerId;
            ViewData["deptId"] = deptId;
            return View();
        }
    }
}
